<template>
	<view>
		<view class="header">
			<view class="header_box">
				<image src="../../static/pages_my/header_bg.png" class="bg" mode=""></image>
				<view class="box1" v-if="info" :style="'margin-top: '+safeT+'px'">
					<view class="l">
						<image class="avatar" :src="$oss(info.avatar)" mode="aspectFill"></image>
						<view class="info">
							
							<view class="phone">{{info.mobile}}</view>
							<view class="phone">{{info.levelinfo.name}}
								<image :src="$oss(info.levelinfo.image)" class="phone_img" mode=""></image>
							</view>
						</view>
						<image class="viptips" v-if="info.userplus==1" src="../../static/pages_my/viptips.png"
							mode="aspectFill"></image>
					</view>
					<view class="r" @click="$authTo('/pages_my/myinfo/myinfo')">
						<view class="u-m-r-10">修改资料</view>
						<u-icon name='play-right-fill'></u-icon>
					</view>
				</view>
				<view class="box1" v-else :style="'margin-top: '+safeT+'px'" @click="$login">
					<view class="l">
						<image class="avatar" :src="$oss($store.state.config.user_logo_image)" mode=""></image>
						<view class="info">
							<view class="name">{{$store.state.config.user_name}}</view>

						</view>
					</view>
					<view class="r">
						<text>请登录</text>
						<image src="../../static/pages_technician/right_grey.png" mode=""></image>
					</view>
				</view>
				<!-- <view class="menber flex" @click="$authTo('/pages_my/openVip/openVip')">
					<image class="menberimg" src="/static/pages_my/vipBg.png" mode=""></image>
					<view class="flex" style="align-items: center;">
						<image class="hg" src="../../static/pages_my/hg.png" mode="aspectFill"></image>
						<view class="menbertext flex">
							<view class="menbertext_top">扫扫会员</view>
							<view class="menbertext_bottom">开通会员可享受会员价特权</view>
						</view>
					</view>
					<view class="menberbtn" v-if="info.userplus==1">
						续费会员
					</view>
					<view class="menberbtn" v-else>
						开通会员
					</view>
					
				</view> -->
				<view class="box2">
					<view class="box2_top flex">
						<view class="box2_top_left flex">
							<view class="">账户余额(元)</view>
							<view class="u-font-bold u-font-50 u-m-t-20">￥{{info.money||0}}</view>
						</view>
						<view class="box2_top_btn u-font-26"
							@click="$authTo('/pages_my/accountBalance/accountBalance')">
							立即充值
						</view>
					</view>
					<view class="towbox flex">
						<view class="towbox_item flex u-m-r-30" @click="$authTo('/pages_my/collect/collect')">
							<view class="towbox_item_left">
								<view class="textone">我的收藏</view>
								<view class="texttwo u-m-t-20 u-font-26">已收藏 {{info.collectCount||0}} 人</view>
							</view>
							<image class="towbox_item_image" src="../../static/pages_my/clect.png" mode=""></image>
						</view>
						<view class="towbox_item flex" @click="$authTo('/pages_my/coupons/coupons')">
							<view class="towbox_item_left">
								<view class="textone">优惠券</view>
								<view class="texttwo u-m-t-20 u-font-26">{{info.couponNum||0}}张优惠券</view>
							</view>
							<image class="towbox_item_image" src="../../static/pages_my/yhq.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="body_box1">
			<view class="lqzx" @click="$authTo('/pages_my/collectingVouchers/collectingVouchers')">
				<view class="l">
					<view class="label">领券中心</view>
					<view class="name">海量优惠券</view>
				</view>
				<image src="../../static/pages_my/icon1.png" mode=""></image>
			</view>
			<view class="lqzx lxkf" @click="service">
				<view class="l">
					<view class="label">联系客服</view>
					<view class="name">24小时在线</view>
				</view>
				<image src="../../static/pages_my/icon2.png" mode=""></image>
			</view>
		</view>

		<view class="body_box2" v-if="info ==='' || info.usertype === 0">
			<view class="item" v-for="(i,idx) in arr1" @click="$authTo(i.url)" :key="idx">
				<image :src="i.icon" mode=""></image>
				<text>{{i.name}}</text>
			</view>
		</view>
		<view class="body_box2 body_box3">
			<view class="item" @click="$authTo(i.path)" v-for="(i,idx) in arr2" :key="idx"
				v-if="info === '' || i.type === '' || (info && info.usertype === i.type)">
				<image :src="i.icon" mode=""></image>
				<text>{{i.name}}</text>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr1: [{
						name: '技师入驻',
						icon: '/static/pages_my/icon3.png',
						url: '/pages_my/jsrz/jsrz'
					},
					{
						name: '代理申请',
						icon: '/static/pages_my/icon4.png',
						url: '/pages_my/dlsq/dlsq'
					},
					{
						name: '渠道入驻',
						icon: '/static/pages_my/icon5.png',
						url: '/pages_my/qdrz/qdrz'
					},
					{
						name: '业务员入驻',
						icon: '/static/pages_my/icon6.png',
						url: '/pages_my/ywyrz/ywyrz'
					},
				],
				arr2: [{
						name: '地址管理',
						icon: '/static/pages_my/icon7.png',
						path: '/pages_my/addressManagement/addressManagement',
						type: ''
					},
					{
						name: '渠道中心',
						icon: '/static/pages_my/icon9.png',
						path: '/pages_my/qudaocenter/qudaocenter',
						type: 5
					},
					{
						name: '业务中心',
						icon: '/static/pages_my/icon10.png',
						path: '/pages_my/businesscenter/businesscenter',
						type: 6
					},
					{
						name: '邀请好友',
						icon: '/static/pages_my/icon11.png',
						path: '/pages_my/newinvite/newinvite',
						type: 0
					},
					{
						name: '基础设置',
						icon: '/static/pages_my/icon13.png',
						path: '/pages_my/baseset/baseset',
						type: ''
					},
					{
						name: '我的魔豆',
						icon: '/static/pages_my/modou.png',
						path: '/pages_my/modou/modou',
						type: ''
					}, {
						name: '意见反馈',
						icon: '/static/pages_my/idea.png',
						path: '/pages/idea/idea',
						type: ''
					},
					// {
					// 	name: '我的会员',
					// 	icon: '/static/pages_my/vip.png', 
					// 	path: '/pages_my/openVip/openVip',
					// 	type: ''
					// },

				],
				info: '',
				safeT: ''

			}
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.getInfo()
			}

		},
		onLoad() {
			// #ifdef MP
			this.safeT = uni.getSystemInfoSync().statusBarHeight + 50;
			// #endif
			// #ifdef APP
			this.safeT = uni.getSystemInfoSync().statusBarHeight + 30;
			// #endif
			// #ifdef H5
			this.safeT = uni.getSystemInfoSync().statusBarHeight + 30;
			// #endif
		},
		methods: {
			service() {
				// #ifdef MP-WEIXIN
				wx.openCustomerServiceChat({
					extInfo: {
						url: this.$store.state.config.firm_wechat_url
					},
					corpId: this.$store.state.config.firm_wechat_appid,
					success(res) {

					}
				})
				// #endif
				// #ifdef H5
				window.location.href = this.$store.state.config.firm_wechat_url
				// #endif
				// #ifdef APP
				uni.share({
					provider: "weixin",
					corpid: this.$store.state.config.firm_wechat_appid,
					openCustomerServiceChat: true,
					customerUrl: this.$store.state.config.firm_wechat_url,
					success: function(res) {

					},
					fail: function(err) {

					}
				});
				// #endif
			},
			getInfo() {
				this.$api.post('/index', {}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.info = res.data
					}
				}).catch((res) => {})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F7F7FA;
	}

	.header {
		background-color: #fff;
		// border-radius: 0rpx 0rpx 30rpx 30rpx;
	}

	.header_box {
		width: 750rpx;
		overflow: hidden;
		position: relative;

		.bg {
			width: 750rpx;
			position: absolute;
			left: 0;
			top: 0;
		}

		.box1 {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 32rpx;
			margin-top: 170rpx;
			position: relative;
			z-index: 10;

			.l {
				display: flex;
				align-items: center;
				position: relative;

				.viptips {
					position: absolute;
					width: 54rpx;
					height: 28rpx;
					bottom: -10rpx;
					left: 25rpx;
				}

				.avatar {
					width: 105rpx;
					height: 105rpx;
					border-radius: 50%;
					margin-right: 30rpx;
				}

				.info {
					.name {
						font-size: 36rpx;
						color: #1C274C;
						font-weight: bold;
					}

					.phone {
						font-size: 26rpx;
						color: #8D93A5;
						font-weight: bold;
						display: flex;
						align-items: center;

						.phone_img {
							width: 50rpx;
							height: 50rpx;
						}
					}
				}
			}

			.r {
				width: 169rpx;
				height: 60rpx;
				background: #fff;
				border-radius: 15rpx;
				border: 1rpx solid #FFFFFF;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 24rpx;
				font-weight: 500;
				color: #1C274C;

				image {
					width: 9rpx;
					height: 14rpx;
					margin-left: 10rpx;
				}
			}
		}

		.box2 {
			align-items: center;
			margin: 30rpx auto 0;
			position: relative;
			width: 90vw;
			// padding-bottom: 30rpx;
			background-color: #00CE9B;
			border-radius: 20rpx 20rpx 0 0;

			.box2_top {
				padding: 30rpx;
				width: 100%;
				align-items: center;
				justify-content: space-between;
				box-sizing: border-box;

				.box2_top_left {
					color: #fff;
					flex-direction: column;
					justify-content: space-between;
				}

				.box2_top_btn {
					color: #00CE9B;
					background: linear-gradient(to bottom, #F2FFFC, #CBFFF2);
					padding: 15rpx 40rpx;
					border-radius: 40rpx;
				}
			}

			.towbox {
				width: 100%;
				justify-content: space-between;
				align-items: center;
				padding: 30rpx;
				box-sizing: border-box;

				.towbox_item {

					align-items: center;
					justify-content: space-between;
					background-color: #fff;
					border-radius: 20rpx;
					padding: 30rpx;

					.towbox_item_left {
						.textone {
							color: #1C274C;
							font-weight: bold;
						}

						.texttwo {
							color: #959AAC;
						}
					}

					.towbox_item_image {
						width: 72rpx;
						height: 73rpx;
					}
				}
			}

			.item {
				flex: 1;
				flex-shrink: 0;
				display: flex;
				flex-direction: column;
				align-items: center;

				.label {
					font-size: 24rpx;
					color: #1C274C;
				}

				.num {
					font-size: 40rpx;
					font-weight: 900;
					color: #1C274C;

					.fuhao {
						font-size: 24rpx;
						margin-right: 2rpx;
					}
				}
			}
		}

		.box3 {
			width: 686rpx;
			height: 138rpx;
			margin: 60rpx auto 0;
			background: url(/static/pages_my/vipBg.png) no-repeat;
			background-size: 686rpx auto;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 40rpx;
			box-sizing: border-box;
			position: relative;
			z-index: 10;

			.l {
				display: flex;
				align-items: center;

				image {
					width: 88rpx;
					height: 69rpx;
					margin-right: 24rpx;
				}

				.vip {
					.name {
						font-size: 32rpx;
						color: #F4C889;
						font-weight: bold;
						margin-bottom: 10rpx;
					}

					.text {
						font-size: 20rpx;
						color: #B8A789;
					}
				}
			}

			.btn {
				width: 150rpx;
				height: 56rpx;
				background: linear-gradient(90deg, #F2CC9A 0%, #DFB173 100%);
				border-radius: 28rpx;
				text-align: center;
				line-height: 56rpx;
				font-size: 22rpx;
				font-weight: 500;
				color: #57331F;
			}
		}
	}

	.menber {
		position: relative;
		width: 90vw;
		height: 140rpx;
		margin: 30rpx auto;
		align-items: center;
		justify-content: space-between;

		.menberimg {
			width: 90vw;
			height: 140rpx;
			position: absolute;
		}

		.hg {
			width: 88rpx;
			height: 70rpx;
			margin: 30rpx;
			position: relative;
		}

		.menbertext {
			flex-direction: column;
			justify-content: space-around;
			height: 70rpx;
			position: relative;

			.menbertext_top {
				color: #F4C889;
				font-size: 32rpx;
				font-weight: bold;
			}

			.menbertext_bottom {
				font-size: 26rpx;
				color: #B8A789;
			}
		}

		.menberbtn {
			font-size: 26rpx;
			position: relative;
			color: #57331F;
			background: linear-gradient(90deg, #F2CC9A 0%, #DFB173 100%);
			border-radius: 30rpx;
			padding: 10rpx 30rpx;
			margin-right: 20rpx;
		}
	}

	.body_box1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 32rpx;
		box-sizing: border-box;
		margin-top: 40rpx;

		.lqzx {
			width: 328rpx;
			height: 150rpx;
			background: #FFEAEA;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 32rpx;
			box-sizing: border-box;

			.l {
				.label {
					font-size: 28rpx;
					font-weight: 600;
					color: #FF5A70;
				}

				.name {
					font-size: 22rpx;
					color: #FF96A4;
					margin-top: 10rpx;
				}
			}

			image {
				width: 75rpx;
				height: 75rpx;
			}
		}

		.lxkf {
			background: #EBF0FF;

			.l {
				.label {
					color: #5982FF;
				}

				.name {
					color: #97B1FF;
				}
			}
		}
	}

	.body_box2 {
		width: 686rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: 40rpx auto 0;
		display: flex;
		padding: 40rpx 0;
		box-sizing: border-box;
		flex-wrap: wrap;

		.item {
			width: 25%;
			font-size: 24rpx;
			font-weight: 500;
			color: #1C274C;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 50rpx;
				height: 50rpx;
				margin-bottom: 10rpx;
			}
		}
	}

	.body_box3 .item:nth-child(n+5) {
		margin-top: 40rpx;
	}
</style>